 <%@ Page Language="VB" MasterPageFile="~/site.master" AutoEventWireup="false" codefile="Scorers.aspx.vb" Inherits="Scorers" %>                                                                                                                                                                                                                                                                     
<asp:Content ID="Content1" ContentPlaceHolderID="mainContent" Runat="server">

    <asp:sqldatasource id="SqlDataSource1" runat="server" selectcommand="SELECT  Count(*) AS [TotalGoals],[Goals].[PlayerID], [FirstName],[LastName] FROM [Goals]  INNER JOIN [Players] ON [Goals].[PlayerID] = [Players].[Playerid] GROUP BY [Goals].[PlayerID],[FirstName],[LastName] HAVING Count(*)>0  ORDER BY [TotalGoals] DESC"
        connectionstring="<%$ ConnectionStrings:WroxUnited %>"></asp:sqldatasource>
        
    <asp:gridview id="GridView1" runat="server" datakeynames="PlayerID" datasourceid="SqlDataSource1"
        emptydatatext="There are no data records to display." autogeneratecolumns="False"
        allowpaging="True" allowsorting="False">
        <Columns>
            <asp:CommandField ShowSelectButton="True"></asp:CommandField>
            <asp:BoundField ReadOnly="True" HeaderText="PlayerID" DataField="PlayerID" SortExpression="PlayerID" Visible="False"></asp:BoundField>
            <asp:BoundField ReadOnly="True" HeaderText="FirstName" DataField="FirstName" SortExpression="FirstName" Visible="True"></asp:BoundField>
            <asp:BoundField ReadOnly="True" HeaderText="LastName" DataField="LastName" SortExpression="LastName" Visible="True"></asp:BoundField>
            <asp:BoundField ReadOnly="True" HeaderText="TotalGoals" DataField="TotalGoals" SortExpression="TotalGoals" Visible="True"></asp:BoundField>
        </Columns>
    </asp:gridview>
    
        <asp:sqldatasource id="SqlDataSource2" runat="server"
        selectcommand="SELECT [FirstName], [LastName], [Position], [DateJoined], [PictureURL] FROM [Players] WHERE ([PlayerID] = @PlayerID)"
        connectionstring="<%$ ConnectionStrings:WroxUnited %>">
        <SelectParameters>
            <asp:ControlParameter Name="PlayerID" Type="Int32" ControlID="GridView1" PropertyName="SelectedValue"></asp:ControlParameter>
        </SelectParameters>
    </asp:sqldatasource>

    <p />
    <asp:repeater id="Repeater1" runat="server" datasourceid="SqlDataSource2">
        <Itemtemplate>
            <p>
            <div class="itemTitle">
                <asp:Label Text='<%# Bind("FirstName") %>' runat="server" id="FirstNameLabel" />  
            
            <asp:Label Text='<%# Bind("LastName") %>' runat="server" id="LastNameLabel" /></div>
            </p>  <p> 
             <asp:image ImageUrl='<%# Eval("PictureURL", "~/PlayerImages/{0}") %>' runat="server" id="PictureURImage"
                style="float:left; border: none; margin-right: 10px;" /> 
            </p>
            <p>Position: 
            <asp:Label Text='<%# Bind("Position") %>' runat="server" id="Label2" /> 
            </p><p>Date Joined: 
            <asp:Label Text='<%# Eval("DateJoined", "{0:dd-MMM-yy}") %>' runat="server" id="Label3" /> 
            </p>     
        </Itemtemplate>
    </asp:repeater>

</asp:Content>
